# coding: utf-8
import uuid
from marshmallow import Schema, fields
from model.model_base import Base
from sqlalchemy import Column, String, DateTime, TIMESTAMP
from sqlalchemy.ext.hybrid import hybrid_property
import gps_transform


class SuperviseRecord(Base):
    # 督办处理记录表
    __tablename__ = 'SuperviseRecord'
    bureauid = Column(String(2), primary_key=True, comment='供电局编号')
    stationid = Column(String(2), nullable=False, comment='供电所编号')
    openid_station = Column(String(128), nullable=True, comment='供电所人员openid')
    openid = Column(String(128), nullable=True, comment='运维处理人员openid')
    time_station = Column(TIMESTAMP(timezone=True), primary_key=True, comment='供电所人员反馈时间')
    time_operation = Column(TIMESTAMP(timezone=True), nullable=True, comment='运维人员反馈时间')
    flag_result = Column(String(1), nullable=False, comment='运维人员核实标志（0未解决1已解决2供电所已处理3运维组协助4运维组反馈未解决）')
    meter_barcode = Column(String(50), primary_key=True, comment='电能表条码号')
    remark_station = Column(String(200), nullable=True, comment='供电所反馈备注')
    photo_fingerprint = Column(String(100), nullable=True, comment='图片指纹')  # 用于存储medieid
    serial_number = Column(String(32), primary_key=True, comment='初始序列号')#用于存储对应wordrecord表中的序列号
    serial_number_operation = Column(String(32), nullable=True, comment='运维处理序列号')
    bureauname = Column(String(50), nullable=True, comment='县局名称')
    stationname = Column(String(50), nullable=True, comment='供电所名')
    name_station = Column(String(50), nullable=True, comment='供电所人员名称')
    name_operation = Column(String(50), nullable=True, comment='运维人员名称')
    time_problem = Column(TIMESTAMP(timezone=True), nullable=True, comment='问题发现时间')
    problemid = Column(String(2), nullable=True, comment='问题编号')
    proname = Column(String(50), nullable=False, comment='问题名称')
    remark_operation = Column(String(255), nullable=True, comment='运维核实备注')
    photo_fingerprint_operation = Column(String(100), nullable=True, comment='运维图片指纹')  # 用于存储medieid

class SuperviseRecordSchema(Schema):
    bureauid = fields.String()
    stationid = fields.String()
    openid_station = fields.String()
    openid = fields.String()
    time_station = fields.DateTime(format="%Y-%m-%d %H:%M:%S.%f")
    time_operation = fields.DateTime(format="%Y-%m-%d %H:%M:%S.%f")
    flag_result = fields.String()
    meter_barcode = fields.String()
    remark_station = fields.String()
    photo_fingerprint = fields.String()
    serial_number = fields.String()
    serial_number_operation = fields.String()
    bureauname = fields.String()
    stationname = fields.String()
    name_station = fields.String()
    name_operation = fields.String()
    time_problem = fields.DateTime(format="%Y-%m-%d %H:%M:%S.%f")
    problemid = fields.String()
    proname = fields.String()
    remark_operation = fields.String()
    photo_fingerprint_operation = fields.String()



superviseRecordSchema = SuperviseRecordSchema()
